/**
 * 
 */
package com.suyx.job.utils.mh;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.suyx.job.utils.ScreenCapture;

import lombok.extern.slf4j.Slf4j;

/**
 * @author syx
 *
 */
@Slf4j
@Component
public class ZzgScene {

	@Autowired
	private WaTuUtils waTuUtils;
	
	public final static Map<String,String> options_x = new HashMap<>();  
	public final static Map<String,String> options_y = new HashMap<>();
	static {  
		options_x.put("0", "708 300");  
		options_x.put("1", "417 200");  
		options_x.put("2", "517 200");
		options_x.put("3", "617 200"); 
		options_x.put("4", "417 300");
		options_x.put("5", "517 300");
		options_x.put("6", "617 300");
		options_x.put("7", "417 400");
		options_x.put("8", "517 400");
		options_x.put("9", "617 400");
		
		options_y.put("0", "844 294");  
		options_y.put("1", "550 197");  
		options_y.put("2", "650 197");
		options_y.put("3", "750 197"); 
		options_y.put("4", "550 297");
		options_y.put("5", "650 297");
		options_y.put("6", "750 297");
		options_y.put("7", "550 397");
		options_y.put("8", "650 397");
		options_y.put("9", "750 397");
	} 
	
	public  void zzg(String device ,String zuobiao,String baoguo) throws Exception{
		//打开包裹
		ScreenCapture.mouseClick(device, "1308 675");
		ScreenCapture.mouseClick(device, "1000 224");// 打开zzg 7
		ScreenCapture.mouseClick(device, "522 422");// 使用
		ScreenCapture.mouseClick(device, "681 219");//
		ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
	}
	
	public  void zzgSceneSame(String device,String zuobiao,String baoguo) throws Exception{
		Thread.sleep(2 * 1000L);
		ScreenCapture.mouseClick(device, "117 68");//打开地图
        ScreenCapture.mouseClick(device, "430 77");// 选x坐标
        String x = zuobiao.split(" ")[0];
        String y = zuobiao.split(" ")[1];
        input_x(device,x);
        ScreenCapture.mouseClick(device, "717 400");
        ScreenCapture.mouseClick(device, "580 79"); // 选y坐标
        input_y(device, y);
        ScreenCapture.mouseClick(device, "850 397");
        ScreenCapture.mouseClick(device, "700 70");  // 前往
        ScreenCapture.mouseClick(device, "1120 54"); //关闭地图
        //开始挖图
        waTuUtils.startWatu(device, zuobiao, baoguo);
	}
	
	public  void input_x(String device,String x){
		for(int i =0;i<x.length();i++){
			char c = x.charAt(i);
			String x_zb = options_x.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, x_zb);
		}
	}
	
	public  void input_y(String device,String y){
		for(int i =0;i<y.length();i++){
			char c = y.charAt(i);
			String y_zb = options_y.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, y_zb);
		}
	}
}
